﻿Shader "Match/Round"
{
    Properties
    {
        _MainTex ("MainText", 2D) = "white"{}
        _Radiu ("Radius", Range(0,0.5)) = 0.5
    }
    SubShader
    {
        //Tags { "RenderType"="Opaque" }
        pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #include "unitycg.cginc"
            sampler2D _MainTex;
            float _Radiu;

            struct Input
            {
                float4 pos : SV_POSITION;
                float2 ModeUV : TEXCOORD0;
                float2 RadiusUV : TEXCOORD1;
            };
            Input vert(appdata_base v)
            {
                Input o;
                o.pos=UnityObjectToClipPos(v.vertex);
                o.ModeUV=v.texcoord;
                o.RadiusUV=v.texcoord-float2(0.5,0.5);
                return o;
            }
            fixed4 frag(Input i):COLOR
            {
                fixed4 col;
                col=(0,1,1,0);
                if(abs(i.RadiusUV.x)<0.5-_Radiu || abs(i.RadiusUV.y)<0.5-_Radiu)
                {
                    col=tex2D(_MainTex, i.ModeUV);
                }
                else
                {
                    if(length(abs(i.RadiusUV)-float2(0.5-_Radiu,0.5-_Radiu))<_Radiu)
                    {
                        col=tex2D(_MainTex,i.ModeUV);
                    }
                    else
                    {
                        discard;
                    }
                }
                return col;
            }
            ENDCG
        }
    }
}

